<?php
/**注意此文档为UTF-8的编码.
 * Created on 2010-9-23
 *
 * @author EXT <isrn@qq.com>
 *
 */
include ('../../includes/global.php');
include ('../global.php');
include ("../power.php");
$xajax = new xajax();
$xajax->configure('javascript URI', Js_path."/Plug-in/xajax/");
			
function loadsuo($isCaps)
{
	$objResponse = new xajaxResponse();
$temp=Dgd(array(//
		  'db'=>'d_sevenel',
		  'tn'=>"ikeyw",
		  //'column'=>" id, name , sex ",
		  'cd'=>"hexid like '".$isCaps."'",
		  'limit'=>1
		  //'ce'=>1,
		  //'tp'=>'love',
		  //'rt'=>'serialize',
		  //'start'=>'5'
		  ));
if($temp){
	$objResponse->assign('oh', 'value', $temp['wh']);
	$objResponse->assign('ol', 'value', $temp['wl']);
	$objResponse->assign('wh', 'value', $temp['wh']);
	$objResponse->assign('wl', 'value', $temp['wl']);
	$objResponse->assign('orh', 'value', $temp['rh']);
	$objResponse->assign('orl', 'value', $temp['rl']);
	$objResponse->assign('rh', 'value', $temp['rh']);
	$objResponse->assign('rl', 'value', $temp['rl']);
	}else{
	$objResponse->alert('此锁还没有入库');
		}
$temp=Dgd(array(//
		  'db'=>'d_sevenel',
		  'tn'=>"ikey",
		  //'column'=>" id, name , sex ",
		  'cd'=>"hexid like '".$isCaps."'",
		  'limit'=>1
		  //'ce'=>1,
		  //'tp'=>'love',
		  //'rt'=>'serialize',
		  //'start'=>'5'
		  ));
if($temp){
	$objResponse->assign('user', 'value', $temp['user']);
	$objResponse->assign('newuser', 'value', $temp['user']);
	$objResponse->assign('psw', 'value', $temp['psw']);
	$objResponse->assign('newpsw', 'value', $temp['psw']);
	$objResponse->assign('jia2', 'value', $temp['szqz']);
	}else{
	$objResponse->alert('此锁还没有入库');
		}

//	$objResponse->assign('div1', 'innerHTML', $text);
	return $objResponse;
}

$xajax->registerFunction("loadsuo");
$xajax->processRequest();

$xajax->printJavascript();
?>
<SCRIPT>
var lm, a,b,path,c,d,rh,rl,wh,wl,len;
var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
function toHex( n ) {
        var result = ''
        var start = true;
        for ( var i=32; i>0; ) {
                i -= 4;
                var digit = ( n >> i ) & 0xf;
                if (!start || digit != 0) {
                        start = false;
                        result += digitArray[digit];
                }
        }
        return ( result == '' ? '0' : result );
}
	lm=new  ActiveXObject("Syunew3A.s_simnew3");
			path=lm.FindPort(0);
function testsuo(){
		try{	
			if(lm.LastError!=0){
				alert('没有找到加密锁，请插入加密锁');
				}else{
				alert('锁正常可以使用！');
				}
			}
		catch (e){
			alert("请安装驱动程序后再进行操作登录。");
		}
	}
function gethexid(){
	form1.hexid.value=toHex(lm.GetID_1(path))+toHex(lm.GetID_2(path));		
	}
function getuserpsw(){
					mylen=lm.YRead(0,form1.orh.value,form1.orl.value,path);
					form1.user.value=lm.YReadString(1,mylen, form1.orh.value,form1.orl.value, path);
					mylen=lm.YRead(20,form1.orh.value,form1.orl.value,path);
					form1.psw.value=lm.YReadString(21,mylen,form1.orh.value,form1.orl.value, path);
					}
function chagewrightpsw(){
	form1.ws.value=lm.SetWritePassword(form1.oh.value,form1.ol.value,form1.wh.value,form1.wl.value,path);
	form1.oh.value=form1.wh.value;
	form1.ol.value=form1.wl.value;
					}
function chagereadpsw(){
	form1.rs.value=lm.SetReadPassword(form1.oh.value,form1.ol.value,form1.rh.value,form1.rl.value,path);
	form1.orh.value=form1.rh.value;
	form1.orl.value=form1.rl.value;
					}
function chageuserpsw(){
	form1.us.value=lm.YWriteString(form1.newuser.value, 1,form1.oh.value,form1.ol.value,path);
	lm.YWrite(form1.us.value, 0,form1.oh.value,form1.ol.value,path);
	form1.ps.value=lm.YWriteString(form1.newpsw.value, 21,form1.oh.value,form1.ol.value,path);
	lm.YWrite(form1.ps.value, 20,form1.oh.value,form1.ol.value,path);
					}
function jiami(){
	form1.js.value=lm.sWrite(form1.jia1.value,path);
	form1.jia2.value=lm.sread(path);
					}
					
function juemi(){
	form1.jus.value=lm.sWrite_2(form1.jue1.value,path);
	form1.jue2.value=lm.sread(path);
					}
					
					
</SCRIPT>

<html>
<head>
<style type="text/css">

table {border-collapse:collapse;}
thead th {
font:bold 13px/18px georgia;
text-align:left;
background:#D1DDEF;
color:#333;
padding:8px 16px 8px 8px;
border-right:1px solid #fff;
border-bottom:1px solid #fff;
}
thead th.null {background:#7777CD}
tbody th {
font:bold 12px/15px georgia;
text-align:left;
background:#D1DDEF;
color:#333;
padding:8px;
border-bottom:1px solid #f3f0e4;
border-right:1px solid #fff;
}
tbody td {
font:normal 12px/15px georgia;
color:#333;
padding:8px;
border-right:1px solid #f3f0e4;
border-bottom:1px solid #f3f0e4;
}
/* 这3个是关键   --cssrain.cn */
body {background:#D1DDEF; text-align:center}   

</style>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<div style="width:100%; background-color:#69c;; height:20px; color:#FFF; font-size:12px;margin-bottom: 5px;"><b><img src="../img/icon_alert.gif" border="0"> 网络KEY用户请先安装锁的驱动! <a href="./qd.rar" target="_blank"><img src="../img/icon_attachment.gif" border="0">  驱动下载</a>  <a href="./qdhelp.htm" target="_blank"><img src="../img/icon_info.gif" border="0"> 安装说明 </a></b>  </div>

		<table align="center"><tr><td>

<form action=ikeydb.php id=form1 method=post name="login" >
  <div align="center">
    <P>
      <INPUT type="button"   onClick="testsuo()" value="判断锁正否正常">
    <table >
      <tr>
        <td width="599"><table border=1 width="455">
          <tbody>
            <tr>
              <td width="122" height="30">检测HEXID</td>
              <td width="317"><input name="hexid" id="hexid" value="" size="30"   ></td>
              </tr>
          </tbody>
        </table></td></tr></table>
    <p>
      <INPUT type="button"   onClick="gethexid()" value="得到hexid">
    </p>
    <table >
      <tr>
        <td width="599"><table border=1 width="580">
          <tbody>
            <tr>
              <td width="41" height="30">账号</td>
              <td width="523"><input name="user" id="user" value="" size="60"   ></td>
            </tr>
          </tbody>
        </table>
          <table border=1 width="580">
            <tbody>
              <tr>
                <td width="38" height="30">密码</td>
                <td width="523"><input name="psw" id="psw" value="" size="60"   ></td>
              </tr>
            </tbody>
        </table></td></tr></table>
    <p>
      <INPUT type="button"   onClick="getuserpsw()" value="得到账号密码">
    </p>
    <table >
      <tr>
        <td width="599"><table border=1 width="555">
          <tbody>
            <tr>
              <td height="30">原写密码</td>
              <td>H
                <input name="oh" id="oh4" value="ffffffff" size="10"   >
                L
                <input name="ol" id="ol4" value="ffffffff" size="10"   ></td>
            </tr>
                        <tr>
              <td height="30">原读密码</td>
              <td>H
                <input name="orh" id="oh4" value="ffffffff" size="10"   >
                L
                <input name="orl" id="ol4" value="ffffffff" size="10"   ></td>
            </tr>
          </tbody>
        </table>
          <table border=1 width="553">
            <tr>
              <td height="30">新写密码</td>
              <td>H
                <input name="wh" id="wh" value="ffffffff" size="10" maxlength="8"   >
L
<input name="wl" id="user5" value="ffffffff" size="8" maxlength="8"   >
S
<input name="ws" id="ws" value="ffffffff" size="8"   ></td>
            </tr>
            <tbody>
              <tr>
                <td width="122" height="30">新读密码</td>
                <td width="415">H
                  <input name="rh" id="user6" value="ffffffff" size="10" maxlength="8"   >
L
<input name="rl" id="user7" value="ffffffff" size="8" maxlength="8"   >
S
<input name="rs" id="rs" value="ffffffff" size="8"   ></td>
              </tr>
            </tbody>
          </table></td></tr></table>    <p>
      <INPUT type="button"   onClick="chagewrightpsw()" value="改变写密码">  
      <INPUT type="button"   onClick="chagereadpsw()" value="改变读密码">
    </p>    <table border=1 width="553">
            <tr>
              <td height="30">账号</td>
              <td><input name="newuser" id="newuser" value="ffffffff"  >
                US
                  <input name="us" id="us" value="ffffffff" size="10"   ></td>
            </tr>
            <tbody>
              <tr>
                <td width="122" height="30">密码</td>
                <td width="415"><input name="newpsw" id="newpsw" value="ffffffff"   >
                PS
                <input name="ps" id="ps" value="ffffffff" size="10"   ></td>
              </tr>
            </tbody>
          </table>
    <p>
      <INPUT type="button"   onClick="chageuserpsw()" value="改变用户名密码">  
    <table border=1 width="712">
      <tr>
        <td height="30">加密</td>
        <td><input name="jia1" id="jia1" value="123456"  >
          <input name="jia2" id="jia2" value=""  >
          US
<input name="js" id="js" value="" size="10"   ></td>
      </tr>
      <tbody>
        <tr>
          <td width="122" height="30">解密</td>
          <td width="574"><input name="jue1" id="jue1" value="654321"   >
            <input name="jue2" id="jue2" value=""  >
            PS
<input name="jus" id="jus" value="" size="10"   ></td>
        </tr>
      </tbody>
    </table>
    </td>
    </tr>
    </table>
    <p>
      <INPUT type="button"   onClick="jiami()" value="加密（数字签章颂发）">
      <INPUT type="button"   onClick="juemi()" value="解密（数字签章验证）">
<BR>
      <INPUT type="button"   onClick="xajax_loadsuo(form1.hexid.value);" value="载入">
<input type="submit" value="入库">
</div>
</form>
</td></tr></table>
</body>
</html>
